package org.smi.test2;

import java.util.concurrent.CountDownLatch;

/**
 * @Author: ism
 * @Platform: Mac
 * @Date: 4:43 PM 2019/2/22
 */
public class Worker2 extends Thread {

    private int num;
    private CountDownLatch countDownLatch;

    public Worker2(int num, CountDownLatch countDownLatch) {
        this.num = num;
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        System.out.println("线程->" + num + "<-正在执行...");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程->" + num + "<-执行完毕...\n");
        countDownLatch.countDown();
    }
}
